package FIleInpuSteam;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Readname {
    public static void main(String[] args) {
        //1.创造一个缓冲区输出字节流通道
        try ( BufferedReader br = new BufferedReader(new FileReader("D:\\wc4.txt"));
              BufferedWriter x=new BufferedWriter(new FileWriter("D:\\wc5.txt"));
        ){
            List<String> a=new ArrayList<String>();
            String len;
            while((len=br.readLine())!=null){
                a.add(len);
                Collections.sort(a);
            }
            for (String o : a) {
                x.write("\r\n"+o);

            }
            System.out.print("排序成功");

        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}

